package com.lzj.admin.config;

import com.lzj.admin.inteceptor.NoLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Author: Joseph Xu
 * @Date: 2023/1/7 18:42
 */
//@Configuration
public class MVCConfig extends WebMvcConfigurerAdapter {


    @Bean//单例bean
    public NoLoginInterceptor noLoginInterceptor(){
        return new NoLoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(
                noLoginInterceptor()
        ).addPathPatterns(
                "/**"
        ).excludePathPatterns(
                "/index","/user/login",
                "/css/**","/error/**","/image/**","/js/**","/lib/**"
        );
    }
}
